package com.xcj.cloud.service.impl;


import com.xcj.cloud.entity.Page;
import com.xcj.cloud.entity.User;
import com.xcj.cloud.mapper.UserMapper;
import com.xcj.cloud.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;


    @Override
    public User findUserByName(String username) {

        return userMapper.findUserByName(username);
    }

    @Override
    public int addUser(User tbUser) {
        userMapper.insert(tbUser);
        return 1;
    }
    @Override
    public void upp(User user) {
        userMapper.upp(user);
    }

    @Override
    public User getById(long uid) {
        return userMapper.getById(uid);

    }


    @Override
    public Page page(int page, int limit) {
        List<User> list = userMapper.page(page, limit);
        int count = userMapper.count();
        return new Page(count, list);
    }

    @Override
    public void add(User user) {
        userMapper.addUser(user);
    }

    @Override
    public void delList(long uid) {
        userMapper.del(uid);
    }

    @Override
    public void delList(Collection<Long> ids) {
        userMapper.delList(ids);
    }
}
